package examples.complex.view.personwelcome

import de.saxsys.mvvmfx.FxmlView
import de.saxsys.mvvmfx.InjectViewModel
import de.saxsys.mvvmfx.utils.notifications.NotificationCenter
import examples.complex.viewmodel.personwelcome.PersonWelcomeViewModel
import javafx.event.ActionEvent
import javafx.fxml.FXML
import javafx.fxml.Initializable
import javafx.scene.control.Label

import javax.inject.Inject

/**
 * Created by Misty on 2015/6/6.
 */
class PersonWelcomeView implements FxmlView<PersonWelcomeViewModel>, Initializable {
    @FXML
    private Label welcomeLabel

    @Inject
    private NotificationCenter notificationCenter

    @InjectViewModel
    private PersonWelcomeViewModel viewModel


    @Override
    void initialize(URL location, ResourceBundle resources) {
        welcomeLabel.textProperty().bind(viewModel.welcomeString)
    }

    @FXML
    void closeApplicationButtonPressed(ActionEvent event) {
        notificationCenter.publish("hidePersonWelcome", viewModel.personId)
    }

    PersonWelcomeViewModel getViewModel() {
        return viewModel
    }
}
